package com.wujunshen.dumpling.common.constant;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * 默认常量
 *
 * @author frankwoo
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Constants {
  /** 名称 */
  public static final String NAME = "饺子";
  /** 百分号 */
  public static final String PERCENT = "%";

  /** 默认字符集 */
  public static final String DEFAULT_ENCODING = "UTF-8";
  /** 默认国际化 */
  public static final String DEFAULT_LOCALE = "zh_CN";
  /** Mac */
  public static final String MAC = "Mac";
  /** Windows */
  public static final String WINDOWS = "Windows";
  /** 小数点0 */
  public static final String ZERO_DECIMAL_DIGITS = "0";
  /** 默认描述 */
  public static final String DESCRIPTION = "数据字典";
  /** mysql useInformationSchema */
  public static final String USE_INFORMATION_SCHEMA = "useInformationSchema";

  public static final String IS_NULLABLE = "NO";
  /** N */
  public static final String N = "N";
  /** Y */
  public static final String Y = "Y";

  public static final String MYSQL = ":mysql:";

  public static final String GET_COLUMNS_SQL =
      "SELECT TABLE_NAME,\n"
          + "       COLUMN_NAME,\n"
          + "       COLUMN_TYPE,\n"
          + "       case\n"
          + "           when LOCATE('(', COLUMN_TYPE) > 0\n"
          + "               then replace(substring(COLUMN_TYPE, LOCATE('(', COLUMN_TYPE) + 1), ')', '')\n"
          + "           end COLUMN_LENGTH\n"
          + "FROM INFORMATION_SCHEMA.COLUMNS\n"
          + "WHERE TABLE_SCHEMA = ?";

  public static final int FETCH_SIZE = 4000;

  public static final String GET_PRIMARYS_SQL =
      "SELECT TABLE_SCHEMA AS TABLE_CAT, TABLE_NAME, COLUMN_NAME, SEQ_IN_INDEX AS KEY_SEQ\n"
          + "FROM INFORMATION_SCHEMA.STATISTICS\n"
          + "WHERE TABLE_SCHEMA = ?\n"
          + "  AND INDEX_NAME = 'PRIMARY'\n"
          + "ORDER BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX";
}
